import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        allDqarticleNum: 0,
        userInfo: {
            nowUserId: 0,
            nowUsername: '',
            nowUserAvatar: '',
            nowUserNickname: '',
            nowUserEmail: '',
            nowUserPhone: '',
            nowUserRole: '',
            nowUserSignature: '',
            nowUserArticleNum: 0,
            nowUserCommentNum: 0,
        },
        //标签
        articleTags: {}
    },
    mutations: {
        //更新文章总数
        updateAllDqarticleNum(state,allarticlenum){
            state.allDqarticleNum = allarticlenum
        },
        // 更新用户名
        updateUsername(state, username) {
            state.userInfo.nowUsername = username
        },
        //更新头像
        //更新邮箱
        //更新电话
        //更新个性签名
        //更新用户
        updateDqUser(state, dquser) {
            state.userInfo.nowUserId = dquser.userId
            state.userInfo.nowUsername = dquser.userName
            state.userInfo.nowUserNickname = dquser.nickName
            state.userInfo.nowUserAvatar = dquser.avatar
            state.userInfo.nowUserEmail = dquser.email
            state.userInfo.nowUserPhone = dquser.phoneNumber
            state.userInfo.nowUserSignature = dquser.signature
            state.userInfo.nowUserRole = dquser.role
        },
        // 更新文章数量
        updateArticleNum(state, articlenum) {
            state.userInfo.nowUserArticleNum = articlenum
        },
        // 更新评论数量
        updateCommentNum(state, commentnum) {
            state.userInfo.nowUserCommentNum = commentnum
        },
        //更新标签
        updateArticleTags(state, articletags){
            state.articleTags = articletags
        }
    },
    actions: {},
    getters: {},
    modules: {}

})

export default store